﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using YArchitech.LIB;

namespace YArchitech.HVAC.AuxiliaryCurve
{
	internal class UIDataConfig
	{
		public static Dictionary<string, int> GetBoostSetting()
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (XElement xelement in XElement.Load(UIDataConfig.boostpath).Elements())
			{
				if (!(xelement.Name != "BoostLine"))
				{
					foreach (XAttribute xattribute in xelement.Attributes())
					{
						int value = Convert.ToInt32(xattribute.Value);
						string key = xattribute.Name.ToString();
						dictionary.Add(key, value);
					}
				}
			}
			return dictionary;
		}

		public static void SaveBoostSetting(Dictionary<string, int> dicSet)
		{
			XElement xelement = XElement.Load(UIDataConfig.boostpath);
			foreach (XElement xelement2 in xelement.Elements())
			{
				if (!(xelement2.Name != "BoostLine"))
				{
					foreach (XAttribute xattribute in xelement2.Attributes())
					{
						foreach (KeyValuePair<string, int> keyValuePair in dicSet)
						{
							if (xattribute.Name.ToString() == keyValuePair.Key)
							{
								xattribute.SetValue(keyValuePair.Value);
							}
						}
					}
				}
			}
			xelement.Save(UIDataConfig.boostpath);
		}

		private static string boostpath = Product.InstallLocation + "\\Data\\HYMarkCheck.xml";
	}
}
